from django.db import models


# Create your models here.

class CateModel(models.Model):
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'cate'

    def __str__(self):
        return self.name


class BooksModel(models.Model):
    name = models.CharField(max_length=60)
    img = models.ImageField(upload_to='static/img')
    cate = models.ForeignKey(CateModel, on_delete=models.CASCADE)
    intro = models.CharField(max_length=200, verbose_name='简介')
    price = models.DecimalField(max_digits=8, decimal_places=2)

    class Meta:
        db_table = 'books'

    def __str__(self):
        return self.name
